package vip.liux.contracts.shared.enums.pay;

import vip.liux.core.enums.IEnum;

import java.util.Objects;

public enum PayTransferStatus implements IEnum {

    WAITING(0, "等待转账"),
    PROCESSING(1, "转账进行中"),
    SUCCESS(2, "转账成功"),
    CLOSED(3, "转账关闭");

    /**
     * 类型
     */
    private final int value;
    /**
     * 名字
     */
    private final String desc;

    PayTransferStatus(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static boolean isSuccess(PayTransferStatus status) {
        return Objects.equals(status, SUCCESS);
    }

    public static boolean isSuccess(Integer status) {
        return Objects.equals(status, SUCCESS.getValue());
    }

    public static boolean isClosed(PayTransferStatus status) {
        return Objects.equals(status, CLOSED);
    }

    public static boolean isClosed(Integer status) {
        return Objects.equals(status, CLOSED.getValue());
    }

    public static boolean isWaiting(PayTransferStatus status) {
        return Objects.equals(status, WAITING);
    }

    public static boolean isProcessing(PayTransferStatus status) {
        return Objects.equals(status, PROCESSING);
    }

    public static boolean isProcessing(Integer status) {
        return Objects.equals(status, PROCESSING.getValue());
    }

    /**
     * 是否处于待转账或者转账中的状态
     *
     * @param status 状态
     * @return 是否
     */
    public static boolean isWaitingOrProcessing(PayTransferStatus status) {
        return isWaiting(status) || isProcessing(status);
    }

    /**
     * 是否处于成功或者关闭中的状态
     *
     * @param status 状态
     * @return 是否
     */
    public static boolean isSuccessOrClosed(PayTransferStatus status) {
        return isSuccess(status) || isClosed(status);
    }

    @Override
    public int getValue() {
        return value;
    }

    @Override
    public String getDesc() {
        return desc;
    }

}
